/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * <p>Project: mybatis2022 - AppDemo
 * <p>Powered by webrx On 2022-04-11 09:11:25
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class AppDemo {
    public static void main(String[] args) throws IOException {
        //加载mybatis核心的配置文件
        InputStream is = Resources.getResourceAsStream("mybatis-conf.xml");
        //建立SqlSessionFactory工具类
        SqlSessionFactory sf = new SqlSessionFactoryBuilder().build(is);
        //建立SqlSession
        SqlSession ss = sf.openSession();

        //执行相关的语句 show databases;
        System.out.println(ss.selectList("dbs"));
        System.out.println(ss.selectOne("ver", String.class).toString());
        System.out.println(ss.selectList("tbs"));
        System.out.println(ss.selectList("tbs","mysql"));

        System.out.println(ss.selectMap("shows", ""));

    }
}
